/**
 */
package de.thwildau.tm.moses.asn1.asn1.impl;

import de.thwildau.tm.moses.asn1.asn1.Asn1Package;
import de.thwildau.tm.moses.asn1.asn1.EncodingReferenceDefault;
import de.thwildau.tm.moses.asn1.asn1.ModuleBody;
import de.thwildau.tm.moses.asn1.asn1.ModuleDefinition;
import de.thwildau.tm.moses.asn1.asn1.ModuleIdentifier;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Module Definition</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ModuleDefinitionImpl#getModuleIdentifier <em>Module Identifier</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ModuleDefinitionImpl#getEncodingReferenceDefault <em>Encoding Reference Default</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ModuleDefinitionImpl#getTagDefault <em>Tag Default</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ModuleDefinitionImpl#getExtensionDefault <em>Extension Default</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ModuleDefinitionImpl#getModuleBody <em>Module Body</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ModuleDefinitionImpl extends MinimalEObjectImpl.Container implements ModuleDefinition
{
  /**
   * The cached value of the '{@link #getModuleIdentifier() <em>Module Identifier</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getModuleIdentifier()
   * @generated
   * @ordered
   */
  protected ModuleIdentifier moduleIdentifier;

  /**
   * The cached value of the '{@link #getEncodingReferenceDefault() <em>Encoding Reference Default</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEncodingReferenceDefault()
   * @generated
   * @ordered
   */
  protected EncodingReferenceDefault encodingReferenceDefault;

  /**
   * The default value of the '{@link #getTagDefault() <em>Tag Default</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTagDefault()
   * @generated
   * @ordered
   */
  protected static final String TAG_DEFAULT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getTagDefault() <em>Tag Default</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTagDefault()
   * @generated
   * @ordered
   */
  protected String tagDefault = TAG_DEFAULT_EDEFAULT;

  /**
   * The default value of the '{@link #getExtensionDefault() <em>Extension Default</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExtensionDefault()
   * @generated
   * @ordered
   */
  protected static final String EXTENSION_DEFAULT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getExtensionDefault() <em>Extension Default</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExtensionDefault()
   * @generated
   * @ordered
   */
  protected String extensionDefault = EXTENSION_DEFAULT_EDEFAULT;

  /**
   * The cached value of the '{@link #getModuleBody() <em>Module Body</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getModuleBody()
   * @generated
   * @ordered
   */
  protected ModuleBody moduleBody;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ModuleDefinitionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Asn1Package.Literals.MODULE_DEFINITION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ModuleIdentifier getModuleIdentifier()
  {
    return moduleIdentifier;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetModuleIdentifier(ModuleIdentifier newModuleIdentifier, NotificationChain msgs)
  {
    ModuleIdentifier oldModuleIdentifier = moduleIdentifier;
    moduleIdentifier = newModuleIdentifier;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.MODULE_DEFINITION__MODULE_IDENTIFIER, oldModuleIdentifier, newModuleIdentifier);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setModuleIdentifier(ModuleIdentifier newModuleIdentifier)
  {
    if (newModuleIdentifier != moduleIdentifier)
    {
      NotificationChain msgs = null;
      if (moduleIdentifier != null)
        msgs = ((InternalEObject)moduleIdentifier).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.MODULE_DEFINITION__MODULE_IDENTIFIER, null, msgs);
      if (newModuleIdentifier != null)
        msgs = ((InternalEObject)newModuleIdentifier).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.MODULE_DEFINITION__MODULE_IDENTIFIER, null, msgs);
      msgs = basicSetModuleIdentifier(newModuleIdentifier, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.MODULE_DEFINITION__MODULE_IDENTIFIER, newModuleIdentifier, newModuleIdentifier));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EncodingReferenceDefault getEncodingReferenceDefault()
  {
    return encodingReferenceDefault;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetEncodingReferenceDefault(EncodingReferenceDefault newEncodingReferenceDefault, NotificationChain msgs)
  {
    EncodingReferenceDefault oldEncodingReferenceDefault = encodingReferenceDefault;
    encodingReferenceDefault = newEncodingReferenceDefault;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.MODULE_DEFINITION__ENCODING_REFERENCE_DEFAULT, oldEncodingReferenceDefault, newEncodingReferenceDefault);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setEncodingReferenceDefault(EncodingReferenceDefault newEncodingReferenceDefault)
  {
    if (newEncodingReferenceDefault != encodingReferenceDefault)
    {
      NotificationChain msgs = null;
      if (encodingReferenceDefault != null)
        msgs = ((InternalEObject)encodingReferenceDefault).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.MODULE_DEFINITION__ENCODING_REFERENCE_DEFAULT, null, msgs);
      if (newEncodingReferenceDefault != null)
        msgs = ((InternalEObject)newEncodingReferenceDefault).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.MODULE_DEFINITION__ENCODING_REFERENCE_DEFAULT, null, msgs);
      msgs = basicSetEncodingReferenceDefault(newEncodingReferenceDefault, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.MODULE_DEFINITION__ENCODING_REFERENCE_DEFAULT, newEncodingReferenceDefault, newEncodingReferenceDefault));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getTagDefault()
  {
    return tagDefault;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTagDefault(String newTagDefault)
  {
    String oldTagDefault = tagDefault;
    tagDefault = newTagDefault;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.MODULE_DEFINITION__TAG_DEFAULT, oldTagDefault, tagDefault));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getExtensionDefault()
  {
    return extensionDefault;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExtensionDefault(String newExtensionDefault)
  {
    String oldExtensionDefault = extensionDefault;
    extensionDefault = newExtensionDefault;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.MODULE_DEFINITION__EXTENSION_DEFAULT, oldExtensionDefault, extensionDefault));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ModuleBody getModuleBody()
  {
    return moduleBody;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetModuleBody(ModuleBody newModuleBody, NotificationChain msgs)
  {
    ModuleBody oldModuleBody = moduleBody;
    moduleBody = newModuleBody;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.MODULE_DEFINITION__MODULE_BODY, oldModuleBody, newModuleBody);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setModuleBody(ModuleBody newModuleBody)
  {
    if (newModuleBody != moduleBody)
    {
      NotificationChain msgs = null;
      if (moduleBody != null)
        msgs = ((InternalEObject)moduleBody).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.MODULE_DEFINITION__MODULE_BODY, null, msgs);
      if (newModuleBody != null)
        msgs = ((InternalEObject)newModuleBody).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.MODULE_DEFINITION__MODULE_BODY, null, msgs);
      msgs = basicSetModuleBody(newModuleBody, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.MODULE_DEFINITION__MODULE_BODY, newModuleBody, newModuleBody));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Asn1Package.MODULE_DEFINITION__MODULE_IDENTIFIER:
        return basicSetModuleIdentifier(null, msgs);
      case Asn1Package.MODULE_DEFINITION__ENCODING_REFERENCE_DEFAULT:
        return basicSetEncodingReferenceDefault(null, msgs);
      case Asn1Package.MODULE_DEFINITION__MODULE_BODY:
        return basicSetModuleBody(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Asn1Package.MODULE_DEFINITION__MODULE_IDENTIFIER:
        return getModuleIdentifier();
      case Asn1Package.MODULE_DEFINITION__ENCODING_REFERENCE_DEFAULT:
        return getEncodingReferenceDefault();
      case Asn1Package.MODULE_DEFINITION__TAG_DEFAULT:
        return getTagDefault();
      case Asn1Package.MODULE_DEFINITION__EXTENSION_DEFAULT:
        return getExtensionDefault();
      case Asn1Package.MODULE_DEFINITION__MODULE_BODY:
        return getModuleBody();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Asn1Package.MODULE_DEFINITION__MODULE_IDENTIFIER:
        setModuleIdentifier((ModuleIdentifier)newValue);
        return;
      case Asn1Package.MODULE_DEFINITION__ENCODING_REFERENCE_DEFAULT:
        setEncodingReferenceDefault((EncodingReferenceDefault)newValue);
        return;
      case Asn1Package.MODULE_DEFINITION__TAG_DEFAULT:
        setTagDefault((String)newValue);
        return;
      case Asn1Package.MODULE_DEFINITION__EXTENSION_DEFAULT:
        setExtensionDefault((String)newValue);
        return;
      case Asn1Package.MODULE_DEFINITION__MODULE_BODY:
        setModuleBody((ModuleBody)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.MODULE_DEFINITION__MODULE_IDENTIFIER:
        setModuleIdentifier((ModuleIdentifier)null);
        return;
      case Asn1Package.MODULE_DEFINITION__ENCODING_REFERENCE_DEFAULT:
        setEncodingReferenceDefault((EncodingReferenceDefault)null);
        return;
      case Asn1Package.MODULE_DEFINITION__TAG_DEFAULT:
        setTagDefault(TAG_DEFAULT_EDEFAULT);
        return;
      case Asn1Package.MODULE_DEFINITION__EXTENSION_DEFAULT:
        setExtensionDefault(EXTENSION_DEFAULT_EDEFAULT);
        return;
      case Asn1Package.MODULE_DEFINITION__MODULE_BODY:
        setModuleBody((ModuleBody)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.MODULE_DEFINITION__MODULE_IDENTIFIER:
        return moduleIdentifier != null;
      case Asn1Package.MODULE_DEFINITION__ENCODING_REFERENCE_DEFAULT:
        return encodingReferenceDefault != null;
      case Asn1Package.MODULE_DEFINITION__TAG_DEFAULT:
        return TAG_DEFAULT_EDEFAULT == null ? tagDefault != null : !TAG_DEFAULT_EDEFAULT.equals(tagDefault);
      case Asn1Package.MODULE_DEFINITION__EXTENSION_DEFAULT:
        return EXTENSION_DEFAULT_EDEFAULT == null ? extensionDefault != null : !EXTENSION_DEFAULT_EDEFAULT.equals(extensionDefault);
      case Asn1Package.MODULE_DEFINITION__MODULE_BODY:
        return moduleBody != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (tagDefault: ");
    result.append(tagDefault);
    result.append(", extensionDefault: ");
    result.append(extensionDefault);
    result.append(')');
    return result.toString();
  }

} //ModuleDefinitionImpl
